package 剑指offer_leetcode;

/**
 * JZ4二维数组中的查找
 */
public class 剑指Offer04_二维数组中的查找 {
    public boolean findNumberIn2DArray(int[][] matrix, int target) {
        if(matrix.length==0)
            return false;
        int n = matrix.length;
        int m = matrix[0].length;
        for(int i=n-1,j=0;i>=0&&j<m;){
            if(matrix[i][j]>target)
                i--;
            else if(matrix[i][j]<target)
                j++;
            else
                return true;
        }
        return false;
    }
}
